﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Reflection;

namespace WS.EKA.UI.Business
{
    internal abstract class ReportFactory
    {
        private static Dictionary<WebSocketClientType, IReport> factorys = new Dictionary<WebSocketClientType, IReport>();

        static ReportFactory()
        {
            var assembly = Assembly.GetExecutingAssembly();
            var types = assembly.GetTypes();
            foreach (var type in types)
            {
                if (type.IsClass && type.IsAbstract == false && type.GetInterface("IReport") != null)
                {
                    var obj = Activator.CreateInstance(type) as IReport;
                    factorys[obj.Key] = obj;
                }
            }
        }

        public static IReport GetReportFactory(WebSocketClientType type)
        {
            if (!factorys.ContainsKey(type))
            {
                throw new Exception(type + "类型的业务工厂未实现");
            }
            return factorys[type];
        }

        public static List<IReport> GetAll()
        {
            throw new NotImplementedException();
        }
    }
}